<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Moell\Mojito\Http\Controllers\RoleController as MojitoRoleController;
use Moell\Mojito\Resources\RoleCollection;
use Spatie\Permission\Models\Role;

class RoleController extends MojitoRoleController
{
    /**
     * @author moell<moell91@foxmail.com>
     * @param Request $request
     * @return RoleCollection
     */
    public function index(Request $request)
    {
        return new RoleCollection(Role::query()->where(request_intersect(['name']))->where('aid', 0)->paginate());
    }

    /**
     * @author moell<moell91@foxmail.com>
     * @param $guardName
     * @return RoleCollection
     */
    public function guardNameRoles($guardName)
    {
        return new RoleCollection(Role::query()->where('guard_name', $guardName)->where('aid', 0)->get());
    }
}
